package com.dgw.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dgw.entity.Teacher;
import com.dgw.mapper.TeacherMapper;
import com.dgw.service.TeacherService;
import com.dgw.utils.PageRows;
import com.dgw.utils.StringUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class TeacherServiceImpl implements TeacherService{
	
	@Autowired
	private TeacherMapper teacherMapper;

	@SuppressWarnings("unchecked")
	@Override
	public PageInfo<Teacher> selectByPageAndSelections(String keyword, PageRows pageRows) {
		PageHelper.startPage(pageRows.getCurrentPage(), pageRows.getPageSize());
		List<Teacher> teachers = teacherMapper.selectByPageAndSelections(keyword);
		PageInfo<Teacher> pageInfo = new PageInfo<>(teachers);
		return pageInfo;
	}

	@Override
	public int insert(Teacher teacher) {
		teacher.settId(StringUtil.uuid());
		return teacherMapper.insert(teacher);
	}

	@Override
	public int updateByPrimaryKeySelective(Teacher teacher) {
		return teacherMapper.updateByPrimaryKeySelective(teacher);
	}

	@Override
	public Teacher selectByPrimaryKey(String tId) {
		return teacherMapper.selectByPrimaryKey(tId);
	}
}
